package org.examples.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedisConfig {
    private static final String REDISSION_PREFIX = "redis://";

    @Value("${spring.redis.host}")
    private String redisHost;

    @Value("${spring.redis.port}")
    private String redisPort;

    @Value("${spring.redis.redis-mode}")
    private String redisMode;

    @Bean
    public RedissonClient redissonSingleClient(){
        Config config = new Config();
        config.useSingleServer().setAddress(REDISSION_PREFIX + redisHost + ":" + redisPort);
        return Redisson.create(config);
    }
}
